package com.zmq.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorRule implements WebMvcConfigurer {
    @Autowired
    private MyInterceptor myInterceptor;

    /**
     * 拦截器规则
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有请求
        registry.addInterceptor(myInterceptor).addPathPatterns("/**")
                //放过请求
                //.excludePathPatterns("/*")
                .excludePathPatterns("/static/**")  //静态文件路径
                .excludePathPatterns("/login")      //登录的方法
                .excludePathPatterns("/getVerify")  //生成验证码
                .excludePathPatterns("/index.html")
                .excludePathPatterns("/reg.html")
                .excludePathPatterns("/forget.html");
    }
}
